package cn.chinaflame.pagodas.req;

import cn.chinaflame.pagodas.constant.Sysconst;
import cn.chinaflame.pagodas.enums.CodeEnum;
import cn.chinaflame.pagodas.utils.ParamPreconditions;
import com.google.common.base.Strings;

import java.math.BigDecimal;
import java.util.List;

/**
 * @author created by lbq
 * @date 2018年1月9日 上午11:32:17
 **/
public class PaOrderAddReq extends BaseReq {
    private String openid;//openid
    private String sourceOpenid;
    private String memberId;//会员id
    private String mobile;//手机号
    private String invitationId;//邀请id
    private String itemId;//（暂未使用）
    private String orderType;//订单类型：1-供灯；2-祝福；3，我的邀请，4接收邀请,5祈福金
    private String transType;//交易方式：CHARGE-充值；CASHOUT-提现；PAY-消费；REFUND-退款
    private String payType;//支付方式：WECHAT-微信；FASTBANK-银行卡快捷支付；POS-pos机
    private String ip;//IP地址
    private String channel;//交易渠道
    private BigDecimal amount;//金额
    private BigDecimal totalMoney;//总金额
    private String blessName;//被祝福人姓名
    private String blessSex;//被祝福人性别
    private String blessBirth;//被祝福人生日
    private String blessPhonenum;//被祝福人电话
    private String blessAddr;//被祝福人地址
    private String blessWish;//祝福语
    private String praying;
    private String primaryOrderId;  //原订单ID

    private List<PaOrderItemAddReq> itemList;


    @Override
    public void check() {
        ParamPreconditions.checkMemberPrimiaryValid(memberId, mobile, openid, null);
        ParamPreconditions.checkParamsNotEmpty(orderType, transType, channel, itemId);
        ParamPreconditions.checkPriceValid(amount);
        ParamPreconditions.checkTransTypeValid(transType);

        if (!Strings.isNullOrEmpty(mobile))
            ParamPreconditions.checkMobileFmt(mobile);

        for (PaOrderItemAddReq paOrderItemAddReq : itemList) {
            paOrderItemAddReq.check();
        }
        ParamPreconditions.checkChannelValid(channel);
        ParamPreconditions.checkOrderTypeValid(orderType);
        if (Sysconst.ORDER_CHANNEL_WEBCHAT.equals(channel) && Sysconst.ORDER_TYPE_INVITATION.equals(orderType)) {
            ParamPreconditions.checkNotEmpty(sourceOpenid, CodeEnum.FAIL.getCode(), "被邀请人openid不能为空");
            ParamPreconditions.checkNotEmpty(invitationId, CodeEnum.FAIL.getCode(), "邀请信息id不能为空");
        }
    }

    public String getItemId() {
        return itemId;
    }

    public void setItemId(String itemId) {
        this.itemId = itemId;
    }

    public String getInvitationId() {
        return invitationId;
    }

    public void setInvitationId(String invitationId) {
        this.invitationId = invitationId;
    }

    public String getSourceOpenid() {
        return sourceOpenid;
    }

    public void setSourceOpenid(String sourceOpenid) {
        this.sourceOpenid = sourceOpenid;
    }

    public String getOrderType() {
        return orderType;
    }

    public void setOrderType(String orderType) {
        this.orderType = orderType;
    }

    public List<PaOrderItemAddReq> getItemList() {
        return itemList;
    }

    public void setItemList(List<PaOrderItemAddReq> itemList) {
        this.itemList = itemList;
    }

    public String getMobile() {
        return mobile;
    }

    public void setMobile(String mobile) {
        this.mobile = mobile;
    }

    public String getMemberId() {
        return memberId;
    }

    public void setMemberId(String memberId) {
        this.memberId = memberId;
    }

    public String getOpenid() {
        return openid;
    }

    public void setOpenid(String openid) {
        this.openid = openid;
    }

    public String getTransType() {
        return transType;
    }

    public void setTransType(String transType) {
        this.transType = transType;
    }

    public String getPayType() {
        return payType;
    }

    public void setPayType(String payType) {
        this.payType = payType;
    }

    public String getIp() {
        return ip;
    }

    public void setIp(String ip) {
        this.ip = ip;
    }

    public String getChannel() {
        return channel;
    }

    public void setChannel(String channel) {
        this.channel = channel;
    }

    public BigDecimal getAmount() {
        return amount;
    }

    public void setAmount(BigDecimal amount) {
        this.amount = amount;
    }

    public BigDecimal getTotalMoney() {
        return totalMoney;
    }

    public void setTotalMoney(BigDecimal totalMoney) {
        this.totalMoney = totalMoney;
    }

    public String getBlessName() {
        return blessName;
    }

    public void setBlessName(String blessName) {
        this.blessName = blessName;
    }

    public String getBlessSex() {
        return blessSex;
    }

    public void setBlessSex(String blessSex) {
        this.blessSex = blessSex;
    }

    public String getBlessBirth() {
        return blessBirth;
    }

    public void setBlessBirth(String blessBirth) {
        this.blessBirth = blessBirth;
    }

    public String getBlessPhonenum() {
        return blessPhonenum;
    }

    public void setBlessPhonenum(String blessPhonenum) {
        this.blessPhonenum = blessPhonenum;
    }

    public String getBlessAddr() {
        return blessAddr;
    }

    public void setBlessAddr(String blessAddr) {
        this.blessAddr = blessAddr;
    }

    public String getBlessWish() {
        return blessWish;
    }

    public void setBlessWish(String blessWish) {
        this.blessWish = blessWish;
    }

    public String getPraying() {
        return praying;
    }

    public void setPraying(String praying) {
        this.praying = praying;
    }

    public String getPrimaryOrderId() {
        return primaryOrderId;
    }

    public void setPrimaryOrderId(String primaryOrderId) {
        this.primaryOrderId = primaryOrderId;
    }
}
